# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=krbrelayx
pkgver=61.aef69a7
pkgrel=1
pkgdesc='Kerberos unconstrained delegation abuse toolkit.'
arch=('any')
groups=('blackarch' 'blackarch-scanner' 'blackarch-fuzzer' 'blackarch-spoof'
        'blackarch-networking')
url='https://github.com/dirkjanm/krbrelayx'
license=('MIT')
depends=('python2-ldapdomaindump' 'python2' 'python2-argparse' 'python2-ldap3'
         'python2-pycryptodome' 'python2-pyasn1' 'python2-dnspython'
         'python2-pycryptodomex' 'python2-impacket' 'python2-setuptools')
makedepends=('git')
source=("git+https://github.com/dirkjanm/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"

  install -Dm 755 -t "$pkgdir/usr/share/$pkgname" *.py
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  cp -a --no-preserve=ownership lib/ "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname-addspn" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 addspn.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-addspn"

  cat > "$pkgdir/usr/bin/$pkgname-dnstool" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 dnstool.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-dnstool"

  cat > "$pkgdir/usr/bin/$pkgname-printerbug" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 printerbug.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-printerbug"
}

